import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout/layout.vue'

const router = createRouter({
  history: createWebHashHistory(),
  strict: true,
  routes: [
    {
      path: '/',
      name: 'Root',
      component: Layout,
      redirect: '/login',
      meta: {
        hidden: true
      }
    },
    {
      path: '/home',
      name: 'Home',
      component: Layout,
      redirect: '/preview',
      meta: {
        alwaysShow: true
      },
      children: [
        {
          path: '/preview',
          name: 'Preview',
          component: () => import('@/views/preview/preview.vue'),
          meta: {
            title: '预览'
          },
        },
        {
          path: '/settings',
          name: 'Settings',
          redirect: '/local',
          component: () => import('@/views/Settings/settings.vue'),
          meta: {
            title: '配置'
          },
          children: [
            {
              path: '/local',
              name: 'Local',
              component: () => import('@/views/Settings/local.vue'),
              meta: {
                title: '本地'
              },
            }
          ]
        },
        {
          path: '/image-list',
          name: 'ImageList',
          component: () => import('@/views/ImageList/imageList.vue'),
          meta: {
            title: '图片'
          },
        },
      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/Login/login.vue'),
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
  ],
})

export default router
